﻿using System;
using System.Collections.Generic;
using System.Text;
using TTClassLibrary;
using TTServer.Messages;
using libCommonClass;
using TTServer.Controller;
using libAsymmetricEncryption;
using libUtilities;

namespace TTServer.MessageProcessor
{
    public class ResetNMSAuthentificationMessageProcessor : IMessageProcessor
    {
        public bool Process(libCommonClass.TTMessage message, libInterface.IClientInfoProvider clientInfoProvider)
        {
            if (message is ResetNMSAuthentificationMessage)
            {
                ResetNMSAuthentificationMessage msg = (ResetNMSAuthentificationMessage)message;

                AuthenManagement authenManagement = AuthenManagement.getInstance();

                NotifyMessage nm = null;

                if (Global.bEnableNMS == false || authenManagement.isAvailable() == false)
                {
                    nm = new NotifyMessage("NMS invailable");
                }
                else
                {

                    if (authenManagement.Reset())
                    {
                        nm = new NotifyMessage("Authentification session reseted");
                    }
                }

                if (nm != null)
                {
                    clientInfoProvider.AddToMessageQueue(nm);
                }

                return true;
            }

            return false;
        }
    }
}
